//
// CTileBank.java
// Copyright (C) 2010  "Naush" <naush _ hotmail _ fr>
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as
// published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>./* ----------------------------------------------------------------------------







package org.ryzom.nel.threed;

import org.ryzom.nel.misc.IStream;

public class CTileBank {
  private long swigCPtr;
  protected boolean swigCMemOwn;

  public CTileBank(long cPtr, boolean cMemoryOwn) {
    swigCMemOwn = cMemoryOwn;
    swigCPtr = cPtr;
  }

  public static long getCPtr(CTileBank obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nel3dJNI.delete_CTileBank(swigCPtr);
      }
      swigCPtr = 0;
    }
  }

  public CTileBank() {
    this(nel3dJNI.new_CTileBank(), true);
  }

  public int getLandCount() {
    return nel3dJNI.CTileBank_getLandCount(swigCPtr, this);
  }

  public CTileLand getLand(int landIndex) {
    long cPtr = nel3dJNI.CTileBank_getLand__SWIG_0(swigCPtr, this, landIndex);
    return (cPtr == 0) ? null : new CTileLand(cPtr, false);
  }

  public int getTileSetCount() {
    return nel3dJNI.CTileBank_getTileSetCount(swigCPtr, this);
  }

  public CTileSet getTileSet(int tileIndex) {
    long cPtr = nel3dJNI.CTileBank_getTileSet__SWIG_0(swigCPtr, this, tileIndex);
    return (cPtr == 0) ? null : new CTileSet(cPtr, false);
  }

  public int getTileCount() {
    return nel3dJNI.CTileBank_getTileCount(swigCPtr, this);
  }

  public CTile getTile(int tileIndex) {
    long cPtr = nel3dJNI.CTileBank_getTile__SWIG_0(swigCPtr, this, tileIndex);
    return (cPtr == 0) ? null : new CTile(cPtr, false);
  }

  public int addLand(String name) {
    return nel3dJNI.CTileBank_addLand(swigCPtr, this, name);
  }

  public void removeLand(int landIndex) {
    nel3dJNI.CTileBank_removeLand(swigCPtr, this, landIndex);
  }

  public int addTileSet(String name) {
    return nel3dJNI.CTileBank_addTileSet(swigCPtr, this, name);
  }

  public void removeTileSet(int landIndex) {
    nel3dJNI.CTileBank_removeTileSet(swigCPtr, this, landIndex);
  }

  public void xchgTileset(int first, int second) {
    nel3dJNI.CTileBank_xchgTileset(swigCPtr, this, first, second);
  }

  public void clear() {
    nel3dJNI.CTileBank_clear(swigCPtr, this);
  }

  public int getNumBitmap(CTile.TBitmap bitmap) {
    return nel3dJNI.CTileBank_getNumBitmap(swigCPtr, this, bitmap.swigValue());
  }

  public void computeXRef() {
    nel3dJNI.CTileBank_computeXRef(swigCPtr, this);
  }

  public void cleanUnusedData() {
    nel3dJNI.CTileBank_cleanUnusedData(swigCPtr, this);
  }

  public void getTileXRef(int tile, SWIGTYPE_p_int tileSet, SWIGTYPE_p_int number, SWIGTYPE_p_NL3D__CTileBank__TTileType type) {
    nel3dJNI.CTileBank_getTileXRef(swigCPtr, this, tile, SWIGTYPE_p_int.getCPtr(tileSet), SWIGTYPE_p_int.getCPtr(number), SWIGTYPE_p_NL3D__CTileBank__TTileType.getCPtr(type));
  }

  public long getDisplacementMapCount() {
    return nel3dJNI.CTileBank_getDisplacementMapCount(swigCPtr, this);
  }

  public String getDisplacementMap(long noiseMap) {
    return nel3dJNI.CTileBank_getDisplacementMap__SWIG_0(swigCPtr, this, noiseMap);
  }

  public void setDisplacementMap(long noiseMap, String newName) {
    nel3dJNI.CTileBank_setDisplacementMap(swigCPtr, this, noiseMap, newName);
  }

  public long getDisplacementMap(String fileName) {
    return nel3dJNI.CTileBank_getDisplacementMap__SWIG_1(swigCPtr, this, fileName);
  }

  public void removeDisplacementMap(long mapId) {
    nel3dJNI.CTileBank_removeDisplacementMap(swigCPtr, this, mapId);
  }

  public CTileNoiseMap getTileNoiseMap(long tileNumber, long tileSubNoise) {
    long cPtr = nel3dJNI.CTileBank_getTileNoiseMap(swigCPtr, this, tileNumber, tileSubNoise);
    return (cPtr == 0) ? null : new CTileNoiseMap(cPtr, false);
  }

  public CTileVegetableDesc getTileVegetableDesc(long tileNumber) {
    return new CTileVegetableDesc(nel3dJNI.CTileBank_getTileVegetableDesc(swigCPtr, this, tileNumber), false);
  }

  public void loadTileVegetableDescs() {
    nel3dJNI.CTileBank_loadTileVegetableDescs(swigCPtr, this);
  }

  public void initTileVegetableDescs(CVegetableManager vegetableManager) {
    nel3dJNI.CTileBank_initTileVegetableDescs(swigCPtr, this, CVegetableManager.getCPtr(vegetableManager), vegetableManager);
  }

  public void makeAllPathRelative() {
    nel3dJNI.CTileBank_makeAllPathRelative(swigCPtr, this);
  }

  public void makeAllExtensionDDS() {
    nel3dJNI.CTileBank_makeAllExtensionDDS(swigCPtr, this);
  }

  public void setAbsPath(String newPath) {
    nel3dJNI.CTileBank_setAbsPath(swigCPtr, this, newPath);
  }

  public String getAbsPath() {
    return nel3dJNI.CTileBank_getAbsPath(swigCPtr, this);
  }

  public void postfixTileFilename(String filename) {
    nel3dJNI.CTileBank_postfixTileFilename(swigCPtr, this, filename);
  }

  public void postfixTileVegetableDesc(String filename) {
    nel3dJNI.CTileBank_postfixTileVegetableDesc(swigCPtr, this, filename);
  }

  public void serial(IStream f) {
    nel3dJNI.CTileBank_serial(swigCPtr, this, IStream.getCPtr(f), f);
  }

  public final static class TTileType {
    public final static TTileType _128x128 = new TTileType("_128x128", nel3dJNI.CTileBank__128x128_get());
    public final static TTileType _256x256 = new TTileType("_256x256");
    public final static TTileType transition = new TTileType("transition");
    public final static TTileType undefined = new TTileType("undefined");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TTileType swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TTileType.class + " with value " + swigValue);
    }

    private TTileType(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TTileType(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TTileType(String swigName, TTileType swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TTileType[] swigValues = { _128x128, _256x256, transition, undefined };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
